{% comment %}
Reusable history item card
Expected context: history (LabelPrintHistory instance) and optional search_query
{% endcomment %}
<div class="history-card">
  <div class="history-header">
    <div class="history-info">
      <h6 class="mb-1">
        <i class="fas fa-file-pdf text-danger me-2"></i>
        {{ history.file_name }}
      </h6>
      <div class="config-summary">
        {% with config=history.config_snapshot %}
          <span class="me-3">
            <i class="fas fa-ruler me-1"></i>
            {% if config.size == '18mm' %}小标签(18mm){% elif config.size == '36mm' %}大标签(36mm){% else %}中标签(24mm){% endif %}
          </span>
          <span class="me-3">
            <i class="fas fa-th me-1"></i>
            {{ config.labels_per_page }}个/页
          </span>
          {% if config.include_qr %}
            <span class="me-3">
              <i class="fas fa-qrcode me-1"></i>
              含二维码
            </span>
          {% endif %}
        {% endwith %}
      </div>
    </div>
    <div class="history-meta">
      <div class="mb-1">
        <i class="fas fa-user me-1"></i>
        {{ history.printed_by.username }}
      </div>
      <div class="mb-1">
        <i class="fas fa-clock me-1"></i>
        {{ history.printed_at|date:"Y-m-d H:i" }}
      </div>
      <div>
        <span class="badge bg-primary">{{ history.asset_count }} 个资产</span>
      </div>
    </div>
  </div>

  <!-- 资产编号列表 -->
  <div class="asset-list">
    {% for asset_number in history.get_asset_numbers_list %}
      <span class="asset-tag">{{ asset_number }}</span>
    {% endfor %}
  </div>

  <!-- 文件信息 -->
  <div class="mt-2">
    <small class="text-muted">
      <i class="fas fa-file me-1"></i>
      文件大小:
      {% if history.file_size %}
        {% if history.file_size < 1024 %}
          {{ history.file_size }} B
        {% elif history.file_size < 1048576 %}
          {% widthratio history.file_size 1024 1 %} KB
        {% else %}
          {% widthratio history.file_size 1048576 1 %} MB
        {% endif %}
      {% else %}
        未知
      {% endif %}
    </small>
  </div>
</div>
